#!/usr/bin/env python
import smtplib
from email.mime.text import MIMEText
#############
mailto_list=["hbhzwj@gmail.com"]
#####################
mail_host="YOUR EMAIL HOST"
mail_user="YOUR USER NAME"
mail_pass="YOUR PASSWORD"
mail_postfix="163.com"
######################

def SendTestResult(content):
	if send_mail(mailto_list,"subject: Simulation Result",content):
        	print "Send Success"
    	else:
        	print "SendFail"

def send_mail(to_list,sub,content):
    '''
    to_list:Receiver
    sub:Theme
    content:Content
    send_mail("aaa@126.com","sub","content")
    '''
    me=mail_user+"<"+mail_user+"@"+mail_postfix+">"
    msg = MIMEText(content)
    msg['Subject'] = sub
    msg['From'] = me
    msg['To'] = ";".join(to_list)
    try:
        s = smtplib.SMTP()
        s.connect(mail_host)
        s.login(mail_user,mail_pass)
        s.sendmail(me, to_list, msg.as_string())
        s.close()
        return True
    except Exception, e:
        print str(e)
        return False
if __name__ == '__main__':
    if send_mail(mailto_list,"subject","content, huhu, caicai wo shi shui,caizhong youjiang ou!"):
        print "Send Success"
    else:
        print "SendFail"
